package com.xl.operator;

/**
 * @ClassDescription:
 * @JdkVersion: 1.8
 * @Author: lei·xie
 * @Created: 2024/3/12 0012 11:37
 */
public class OperatorDemo2 {
    public static void main(String[] args) {
        //自增运算符
        int i = 10;
        ++i; //i = i + 1;
        System.out.println(i);
        i--; //i = i - 1;
        System.out.println(i);

        //System.out.println(2--);  //自增自减只能操作变量不能操作字面量，会报错
        System.out.println("-------------------------");
        int a = 10;
        int rs = ++a;  //先加后用
        System.out.println(rs); //11
        System.out.println(a); //11
        System.out.println("-------------------------");
        int b = 10;
        int rs1 = b++; //先用后加
        System.out.println(rs1); //10
        System.out.println(b); //11
        System.out.println("-------------------------");
        int m = 5;
        int n = 3;
        int result = ++m - --m + m-- - ++n + n-- +3; //6-5+5-4+4+3=9
        System.out.println(result); //9
        System.out.println(m); //4
        System.out.println(n); //3

    }
}
